﻿using System;
using System.Net;


namespace CarbonKit.Core.Silverlight3.Extensions {
  using System.Collections;
  using System.Collections.Generic;
  using System.Reflection;

  public static class EnumerableExtensions {

    public static string GetDescription(this Enum value) {
      if (value == null) {
        throw new ArgumentException("value");
      }

      string description = value.ToString();
      FieldInfo fieldInfo = value.GetType().GetField(description);
      EnumDescriptorAttribute[] attributes = (EnumDescriptorAttribute[])fieldInfo.GetCustomAttributes(typeof(EnumDescriptorAttribute), false);
      if (attributes.Length > 0) {
        description = attributes[0].Description;
      }
      return description;
    }

    
  }
}
